package com.yulp.springboot2task.constant;

//  JesqueMsgConstant
public class RetryMessageConstant {

    public static final String SOPAY2CN_RETRY_QUEUE_NAME = "so-pay-2cn-service-retry-queue";
    public static final String SOPAY2CN_RETRY_CLASS_NAME = "SoPay2CnRetryConsumerRunnable";

    public static final String SOCANCEL2CN_RETRY_QUEUE_NAME = "so-cancel-2cn-service-retry-queue";
    public static final String SOCANCEL2CN_RETRY_CLASS_NAME = "SoCancel2CnRetryConsumerRunnable";

    public static final String GRFREFUNDAPPLY_RETRY_QUEUE_NAME = "grf-refund-apply-service-retry-queue";
    public static final String GRFREFUNDAPPLY_RETRY_CLASS_NAME = "GrfRefundApplyRetryConsumerRunnable";

    public static final String GRFDIFFREFUND_RETRY_QUEUE_NAME = "grf-diff-refund-service-retry-queue";
    public static final String GRFDIFFREFUND_RETRY_CLASS_NAME = "GrfDiffRefundRetryConsumerRunnable";

    public static final String GRFAPPLY2CN_RETRY_QUEUE_NAME = "grf-apply-2cn-service-retry-queue";
    public static final String GRFAPPLY2CN_RETRY_CLASS_NAME = "GrfApply2CnRetryConsumerRunnable";

    public static final String GRFSUCCESS2CN_RETRY_QUEUE_NAME = "grf-success-2cn-service-retry-queue";
    public static final String GRFSUCCESS2CN_RETRY_CLASS_NAME = "GrfSuccess2CnRetryConsumerRunnable";

    public static final String WMSDELIVERY2SO_RETRY_QUEUE_NAME = "wms-delivery-2so-service-retry-queue";
    public static final String WMSDELIVERY2SO_RETRY_CLASS_NAME = "WmsDelivery2SoRetryConsumerRunnable";

    public static final String WMSCANCEL2SO_RETRY_QUEUE_NAME = "wms-cancel-2so-service-retry-queue";
    public static final String WMSCANCEL2SO_RETRY_CLASS_NAME = "WmsCancel2SoRetryConsumerRunnable";

    /** 通用：最大重试次数 */
    public static final int MAX_RETRIES = 5;

    /** 通用：重试规则，单位：秒 */
    public static final int[] RETRY_DELAY = new int[]{10, 30, 60, 60, 120, 300};

    public static final String soPay2CnTopic = "soPay2CnTopic";
    public static final int soPay2CnRetries = 0;
    public static final String soCancel2CnTopic = "soCancel2CnTopic";
    public static final int soCancel2CnRetries = 0;

    public static final String grfRefundApplyTopic = "grfRefundApplyTopic";
    public static final int grfRefundApplyRetries = 0;

    public static final String grfDiffRefundTopic = "grfDiffRefundTopic";
    public static final int grfDiffRefundRetries = 0;

    public static final String grfApply2CnTopic = "grfApply2CnTopic";
    public static final int grfApply2CnRetries = 0;

    public static final String grfSuccess2CnTopic = "grfSuccess2CnTopic";
    public static final int grfSuccess2CnRetries = 0;

    public static final String wmsDelivery2SoTopic = "wmsDelivery2SoTopic";
    public static final int wmsDelivery2SoRetries = 0;

    public static final String wmsCancel2SoTopic = "wmsCancel2SoTopic";
    public static final int wmsCancel2SoRetries = 0;

    // TODO 名字可以设置短一些； MsgEnum
    public enum RetryMessageEnum {
        // asdf
        soPay2cn(RetryMessageConstant.SOPAY2CN_RETRY_QUEUE_NAME,
                RetryMessageConstant.SOPAY2CN_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),

        soCancle2cn(RetryMessageConstant.SOCANCEL2CN_RETRY_QUEUE_NAME,
                RetryMessageConstant.SOCANCEL2CN_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),

        grfApply2cn(RetryMessageConstant.GRFAPPLY2CN_RETRY_QUEUE_NAME,
                RetryMessageConstant.GRFAPPLY2CN_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),

        grfSuccess2cn(RetryMessageConstant.GRFSUCCESS2CN_RETRY_QUEUE_NAME,
                RetryMessageConstant.GRFSUCCESS2CN_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),

        grfRefundApply(RetryMessageConstant.GRFREFUNDAPPLY_RETRY_QUEUE_NAME,
                RetryMessageConstant.GRFREFUNDAPPLY_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),

        grfDiffRefund(RetryMessageConstant.GRFDIFFREFUND_RETRY_QUEUE_NAME,
                RetryMessageConstant.GRFDIFFREFUND_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),

        wmsDelivery2So(RetryMessageConstant.WMSDELIVERY2SO_RETRY_QUEUE_NAME,
                RetryMessageConstant.WMSDELIVERY2SO_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),

        wmsCancel2So(RetryMessageConstant.WMSCANCEL2SO_RETRY_QUEUE_NAME,
                RetryMessageConstant.WMSCANCEL2SO_RETRY_CLASS_NAME,
                RetryMessageConstant.MAX_RETRIES,
                RetryMessageConstant.RETRY_DELAY),
        ;
        private String queueName;
        private String className;
        private int maxRetries;
        private int[] retryDelay;

        RetryMessageEnum(String queueName, String className, int maxRetries, int[] retryDelay) {
            this.queueName = queueName;
            this.className = className;
            this.maxRetries = maxRetries;
            this.retryDelay = retryDelay;
        }

        public static RetryMessageEnum getByQueueName(String queueName) {
            RetryMessageEnum[] values = values();
            int value = values.length;

            for (int i = 0; i < value; ++i) {
                RetryMessageEnum retryMessageEnum = values[i];
                if (retryMessageEnum.getQueueName().equals(queueName)) {
                    return retryMessageEnum;
                }
            }
            return null;
        }

        public String getQueueName() {
            return queueName;
        }

        public void setQueueName(String queueName) {
            this.queueName = queueName;
        }

        public String getClassName() {
            return className;
        }

        public void setClassName(String className) {
            this.className = className;
        }

        public int getMaxRetries() {
            return maxRetries;
        }

        public void setMaxRetries(int maxRetries) {
            this.maxRetries = maxRetries;
        }

        public int[] getRetryDelay() {
            return retryDelay;
        }

        public void setRetryDelay(int[] retryDelay) {
            this.retryDelay = retryDelay;
        }

    }
}
